import React, { PureComponent } from 'react';
import { Menu, Icon } from 'antd';
import { Link } from 'react-router-dom';
import './header.css';

const SubMenu = Menu.SubMenu;
const MenuItemGroup = Menu.ItemGroup;

export default class Header extends PureComponent {
  constructor(props){
    super(props)
    this.state={
      token:sessionStorage.getItem("token"),
        userType:sessionStorage.getItem("type")
    };
  }

  render() {
console.log(this.state.userType);
    return (
      <div style={{ maxWidth: 1080, margin: '0 auto' }}>
        <Menu
          selectedKeys={[this.props.current]}
          mode="horizontal"
        >
          <Menu.Item key="homepage" className="menuItem">
            <Link to="/homepage"> <Icon type="mail" />首页</Link>
          </Menu.Item>
          <Menu.Item key="shequ" className="menuItem">
            <Link to="/shequ"><Icon type="appstore" />社区</Link>
          </Menu.Item>
          <Menu.Item key="psytest" className="menuItem">
            <Link to="/psytest"> <Icon type="appstore" />心理测试</Link>
          </Menu.Item>
          <Menu.Item key="userinfo" className="menuItem">
              {
                this.state.token?
                    this.state.userType==2?
                        <Link to="/admin"><Icon type="appstore" />用户管理</Link>
                        :<Link to="/userinfo"><Icon type="appstore" />个人信息</Link>
                :<Link to="/login"><Icon type="appstore" />登录/注册</Link>
              }
          </Menu.Item>
        </Menu>
      </div>
    );
  }
}
